import { Avatar } from "element-ui";


const ACCESSTOKEN = 'accessToken';
const REFRESHTOKEN = 'refreshToken';
const GETUSERS = 'getusers';
const GETBYID = 'getbyids';
const AVATARID='Avatarid';
// 获得token
export function getToken() {
    let token = localStorage.getItem(ACCESSTOKEN);
    return token;
}
export function getUser() {
    let GetUser = localStorage.getItem(GETUSERS);
    return GetUser;
}

export function Getbyids() {
    let getbyids = localStorage.getItem(GETBYID);
    return getbyids;
}
// 获得refreshToken
export function getRefreshToken() {
    let refreshToken = localStorage.getItem(REFRESHTOKEN);
    return refreshToken;
}

// 保存token和refreshToken
export function setToken(accessToken, refreshToken, getusers, Getbyids,Avatarid) {
    if (accessToken && refreshToken) {
        localStorage.setItem(ACCESSTOKEN, accessToken)
        localStorage.setItem(REFRESHTOKEN, refreshToken)
        localStorage.setItem(GETUSERS, getusers)
        localStorage.setItem(GETBYID, Getbyids)
        localStorage.setItem(AVATARID, Avatarid)
    }
    }
// 删除token
export function delToken() {
    localStorage.removeItem(ACCESSTOKEN)
    localStorage.removeItem(REFRESHTOKEN)
    localStorage.removeItem(GETUSERS)
    localStorage.removeItem(AVATARID)
}
// 根据token是否存在，判断当前是否登录
export function isLogin() {
    let token = getToken();
    if (token) {
        return true;
    } else {
        return false;
    }
}